﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

/// <summary>
/// 命名空间，相当于java中的包
/// </summary>
namespace ConsoleApp1
{
    public class Root
    {
        //            {
        //                "messageType": "",
        //	"_server_information_": "HostStatus_key_list:LIMS-Server:8001#uat-8001#10.16.76.33#mvxl24668",
        //	"message": "",
        //	"提醒": "token鉴权已关闭，但不影响当前代码实现！",
        //	"status": "ok",
        //	"token": "1689755757586de12e989-1f69-44b9-91f2-41af0cd728931689755757586"
        //}
        public string message { get; set; }
        public string messageType { get; set; }
        public string status { get; set; }
        public string token { get; set; }
    }


    class DataType
    {
        // 整型
        int a;
        long l;
        short st;

        // 浮点型
        float b;
        double c;

        // 字符和bool型
        char s;
        bool bl;



    }












    /// <summary>
    /// 人类
    /// 
    /// 
    /// </summary>
    class Person
    {
        String name;
        int age;
        Double salary;
        float a;


        public void show()
        {

            Console.WriteLine(" 我是人 ");
        }
    }







    /// <summary>
    /// 程序员类，继承人类
    /// </summary>
    class Coder : Person
    {
        public void show()
        {

            Console.WriteLine(" 我是程序员 ");
        }
    }

    class Utils
    {
        public static String show()
        {
            return "";
        }
    }






    /// <summary>
    /// 默认的类，有Main函数，是程序的主入口
    /// </summary>
    class Program
    {

        private static readonly HttpClient client = new HttpClient();

        

        static void test2()
        {
            // http post 请求
            string tokenUrl = "https://limsuat.midea.com/LIMS-Server/MPLM_Service_Gateway/TokenGenerator/getToken";
            string url = "https://limsuat.midea.com/LIMS-Server/MPLM_Service_Gateway/raclimsRestfulController/updateEquipmentIp";
            string name = "ex_cuiml1";
            string funcName = "getForm";
            string data = "equipmentNumber=A2202020122200001222&ipAddr=10.52.21.36&port=9090&blockName=RAC&bsType=RAC_1&protocol=http";
            string v2 = MyTools.RestfullRequest.LimsPostFormUseToken(tokenUrl, url, name, funcName, data);
            Console.WriteLine(v2);
        }

        static void test1()
        {
            // http post 请求
            string url = "https://limsuat.midea.com/LIMS-Server/MPLM_Service_Gateway/TokenGenerator/getToken";
            string name = "ex_cuiml1";
            string funcName = "getForm";

            string v = MyTools.RestfullRequest.LimsPostToken(url, name, funcName);
            //Console.WriteLine(v);

            Root root = JsonConvert.DeserializeObject<Root>(v);
            //Console.WriteLine(root.token);

            url = "https://limsuat.midea.com/LIMS-Server/MPLM_Service_Gateway/raclimsRestfulController/updateEquipmentIp";


            string data = "equipmentNumber=A2202020122200001222&ipAddr=10.52.21.36&port=9090&blockName=RAC&bsType=RAC_1&protocol=http";
            string v1 = MyTools.RestfullRequest.LimsPostForm(url, name, funcName, root.token, data);
            Console.WriteLine(v1);


            NameValueCollection pas = new NameValueCollection();
            pas.Add("equipmentNumber", "A2202020122200001222123");
            pas.Add("ipAddr", "10.52.21.36");
            pas.Add("port", "9090");
            pas.Add("blockName", "RAC");
            pas.Add("bsType", "RAC_1");
            pas.Add("protocol", "http");

            v1 = MyTools.RestfullRequest.LimsPostForm(url, name, funcName, root.token, pas);
            Console.WriteLine(v1);

        }

        static void test3()
        {

            JsonClass jclass = new JsonClass();
            List<OrderDetailsInsert> orderDetailsInserts = jclass.json2Object();
            Console.WriteLine(orderDetailsInserts.Count);
        }

        static void Main(string[] args)
        {

            //test2();
            //test3();

            // 将一个excel文件转成二进制字节数组
            byte[] bytes = MyTools.ExcelTools.ExcelToBytes("C:\\Users\\Administrator\\Desktop\\123.xlsx");
            Console.WriteLine(bytes.Length);

            // 将二进制字节数组转成excel文件
            MyTools.ExcelTools.BytesToExcel(bytes, "C:\\Users\\Administrator\\Desktop\\1234.xlsx");



            Console.WriteLine("end");
            Console.ReadKey();
        }
    }


    
}
